<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>ATSsinnoi</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="ATSpartialtap.html" title="ATSpartialtap" />
    <link rel="next" href="babo.html" title="babo" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ATSsinnoi</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ATSpartialtap.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="babo.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="ATSsinnoi"></a>
      <div class="titlepage"></div>
      <a id="IndexATSsinnoi" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ATSsinnoi</span>
        </h2>
        <p>ATSsinnoi —  uses the data from an ATS analysis file to perform resynthesis.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp91110928"></a>
        <h2>Description</h2>
        <p>
            <span class="emphasis"><em>ATSsinnoi</em></span> reads data from an ATS data file and uses the information to synthesize sines and noise together.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp91152592"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ar <span class="command"><strong>ATSsinnoi</strong></span> ktimepnt, ksinlev, knzlev, kfmod, iatsfile, ipartials \
          [, ipartialoffset, ipartialincr]</pre>
      </div>
      <div class="refsect1">
        <a id="idp91154816"></a>
        <h2>Initialization</h2>
        <p>
        <span class="emphasis"><em>iatsfile</em></span> – the ATS number (n in ats.n) or the name in quotes of the analysis file made using <a class="ulink" href="http://www-ccrma.stanford.edu/~juan/ATS.html" target="_top"><em class="citetitle">ATS</em></a>.
        </p>
        <p><span class="emphasis"><em>ipartials</em></span> – number of partials that will be used in the resynthesis (the noise has a maximum of 25 bands)
        </p>
        <p><span class="emphasis"><em>ipartialoffset</em></span> (optional) – is the first partial used (defaults to 0).
        </p>
        <p><span class="emphasis"><em>ipartialincr</em></span> (optional) – sets an increment by which these synthesis opcodes counts up from <span class="emphasis"><em>ipartialoffset</em></span> for ibins components in the re-synthesis (defaults to 1).
        </p>
      </div>
      <div class="refsect1">
        <a id="idp91160432"></a>
        <h2>Performance</h2>
        <p><span class="emphasis"><em>ktimepnt</em></span> – The time pointer in seconds used to index the ATS file. Used for <span class="emphasis"><em>ATSsinnoi</em></span> exactly the same as for <a class="link" href="pvoc.html" title="pvoc"><em class="citetitle">pvoc</em></a>.</p>
        <p>
        <span class="emphasis"><em>ksinlev</em></span> - controls the level of the sines in the <span class="emphasis"><em>ATSsinnoi</em></span> ugen. A value of 1 gives full volume sinewaves.
        </p>
        <p><span class="emphasis"><em>knzlev</em></span> - controls the level of the noise components in the <span class="emphasis"><em>ATSsinnoi</em></span> ugen. A value of 1 gives full volume noise.
        </p>
        <p>
        <span class="emphasis"><em>kfmod</em></span> – an input for performing pitch transposition or frequency modulation on all of the synthesized partials, if no fm or pitch change is desired then use a 1 for this value.
        </p>
        <p><span class="emphasis"><em>ATSsinnoi</em></span> reads data from an ATS data file and uses the information to synthesize sines and noise together. The noise energy for each band is distributed equally among each partial that falls in that band. Each partial is then synthesized, along with that partial's noise component. Each noise component is then modulated by the corresponding partial to be put in the correct place in the frequency spectrum. The level of the noise and the partials are individually controllable. See the <a class="ulink" href="http://www-ccrma.stanford.edu/~juan/ATS.html" target="_top"><em class="citetitle">ATS</em></a> webpage for more info about the sinnoi synthesis. An ATS analysis differs from a pvanal in that ATS tracks the partials and computes the noise energy of the sound being analyzed. For more info about ATS analysis read Juan Pampin's description on the the <a class="ulink" href="http://www-ccrma.stanford.edu/~juan/ATS.html" target="_top"><em class="citetitle">ATS</em></a> web-page.
        </p>
      </div>
      <div class="refsect1">
        <a id="idp91170320"></a>
        <h2>Examples</h2>
        <pre class="programlisting">
  ktime   <span class="opc">line</span>       0, p3, 2.5
  asig    <span class="opc">ATSsinnoi</span>  ktime, 1, 1, 1, "beats.ats", 42</pre>
        <p>Here we synthesize both the noise and the sinewaves (all 42 partials) contained in "beats.ats" together. The relative volumes of the noise and the partials are unaltered (each set to 1).
        </p>
        <p>
      Here is another example of the ATSsinnoi opcode. It uses the file <a class="ulink" href="examples/ATSsinnoi.csd" target="_top"><em class="citetitle">ATSsinnoi.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp91175360"></a>
          <p class="title">
            <strong>Example 72. Example of the ATSsinnoi opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o ATSsinnoi.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1	<span class="comment">; "beats.ats" is created by atsa</span>

ktime	<span class="opc">line</span>	0,  p3, 2
knzfade	<span class="opc">expon</span>	0.001, p3, 2
aout	<span class="opc">ATSsinnoi</span> 	ktime, 1, knzfade, 1, "beats.ats", 150
	<span class="opc">outs</span>	aout<span class="op">*</span>2, aout<span class="op">*</span>2		<span class="comment">;amplify some more</span>
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2 
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <br class="example-break" />
        <p>This example here is like the other example except that we use an envelope to control <span class="emphasis"><em>knzlev</em></span> (the noise level). The result of this will be the "beats.wav" sound that has its noise component fade in over the duration of the note.
        </p>
        <p>
      Here is another example of the ATSsinnoi opcode. It uses the file <a class="ulink" href="examples/ATSsinnoi-2.csd" target="_top"><em class="citetitle">ATSsinnoi-2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp91179232"></a>
          <p class="title">
            <strong>Example 73. Example 2 of the ATSsinnoi opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
-odac -d -m128
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="comment">;example by joachim heintz</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

giSine    <span class="ohdr">ftgen</span>     0, 0, 1024, 10, 1
gSfile    <span class="op">=</span>         "fox.ats"
giNumParts <span class="opc">ATSinfo</span>  gSfile, 3 <span class="comment">;overall number of partials</span>
giDur     <span class="opc">ATSinfo</span>   gSfile, 7 <span class="comment">;duration </span>
          <span class="ohdr">seed</span>      0
          

  <span class="oblock">instr</span> PlayList
<span class="opc">event_i</span> "i", "PlayAll", 0, 1, 1, 0, .5 <span class="comment">;sine only, half speed</span>
<span class="opc">event_i</span> "i", "PlayAll", giDur<span class="op">*</span>2<span class="op">+</span>1, 1, 0, 1, .5 <span class="comment">;noise only</span>
<span class="opc">event_i</span> "i", "PlayAll", giDur<span class="op">*</span>4<span class="op">+</span>2, 1, .5, .5, .5 <span class="comment">;half sine, half noise</span>
  <span class="oblock">endin</span>

  <span class="oblock">instr</span> PlayAll
iSinAmnt  <span class="op">=</span>         p4 <span class="comment">;sinee amount (0-1)</span>
iNzAmnt   <span class="op">=</span>         p5 <span class="comment">;noise amount (0-1)</span>
iSpeed    <span class="op">=</span>         p6 <span class="comment">;speed</span>
p3        <span class="op">=</span>         giDur<span class="op">/</span>iSpeed
ktime     <span class="opc">line</span>      0, giDur<span class="op">/</span>iSpeed, giDur
          <span class="opc">prints</span>    "Resynthesizing all <span class="opc">partials</span> with <span class="opc">tone</span> <span class="op">=</span> <span class="op">%</span>.1f and <span class="opc">noise</span> <span class="op">=</span> <span class="op">%</span>.1f.\n", iSinAmnt, iNzAmnt
aOut      <span class="opc">ATSsinnoi</span> ktime, iSinAmnt, iNzAmnt, 1, gSfile, giNumParts
          <span class="opc">outs</span>      aOut, aOut
  <span class="oblock">endin</span>

  <span class="oblock">instr</span> PlayBand
iOffset   <span class="op">=</span>         p4 <span class="comment">;offset in partials</span>
iSpeed    <span class="op">=</span>         p5 <span class="comment">;speed</span>
p3        <span class="op">=</span>         giDur<span class="op">/</span>iSpeed
ktime     <span class="opc">line</span>      0, giDur<span class="op">/</span>iSpeed, giDur
          <span class="opc">prints</span>    "Resynthesizing <span class="opc">partials</span> <span class="op">%</span>d to <span class="op">%</span>d with related noise.\n", iOffset<span class="op">+</span>1, iOffset<span class="op">+</span>10
aOut      <span class="opc">ATSsinnoi</span> ktime, 1, 1, 1, gSfile, 10, iOffset, 1
          <span class="opc">outs</span>      aOut, aOut
<span class="comment">;call itself again</span>
 <span class="octrl">if</span> iOffset <span class="op">&lt;</span> giNumParts <span class="op">-</span> 20 then
          <span class="opc">event_i</span>   "i", "PlayBand", giDur<span class="op">/</span>iSpeed<span class="op">+</span>1, 1, iOffset<span class="op">+</span>10, iSpeed
 <span class="octrl">endif</span>
  <span class="oblock">endin</span>

  <span class="oblock">instr</span> PlayWeighted
  <span class="comment">;sine amount, noise amount and speeed are varying</span>
kSinAmnt  <span class="opc">randomi</span>   0, 1, 1, 3
kNzAmnt   <span class="op">=</span>         1<span class="op">-</span>kSinAmnt
kSpeed    <span class="opc">randomi</span>   .01, .3, 1, 3
async     <span class="opc">init</span>      0
atime, aEnd <span class="opc">syncphasor</span> kSpeed<span class="op">/</span>giDur, async
kTrig     <span class="opc">metro</span>     100
kEnd      <span class="opc">max_k</span>     aEnd, kTrig, 1 <span class="comment">;1 if phasor signal crosses zero</span>
ktime     <span class="opc">downsamp</span>  atime
aOut      <span class="opc">ATSsinnoi</span> ktime<span class="op">*</span>giDur, kSinAmnt, kNzAmnt, 1, gSfile, giNumParts
          <span class="opc">outs</span>      aOut, aOut
  <span class="comment">;exit if file is at the end </span>
  <span class="octrl">if</span> kEnd <span class="op">==</span> 1 then
          <span class="opc">event</span>     "i", "End", 0, 1
  <span class="octrl">endif</span>
  <span class="oblock">endin</span>

  <span class="oblock">instr</span> End
          <span class="opc">exitnow</span>
  <span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> "PlayL<span class="stamnt">i</span>st" 0 1
<span class="stamnt">i</span> "PlayBand" 20 1 0 .5
<span class="stamnt">i</span> "PlayWe<span class="stamnt">i</span>ghted" 110 100
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp91181152"></a>
        <h2>See also</h2>
        <p><a class="link" href="ATSread.html" title="ATSread"><em class="citetitle">ATSread</em></a>, 
            <a class="link" href="ATSreadnz.html" title="ATSreadnz"><em class="citetitle">ATSreadnz</em></a>, 
            <a class="link" href="ATSinfo.html" title="ATSinfo"><em class="citetitle">ATSinfo</em></a>, 
            <a class="link" href="ATSbufread.html" title="ATSbufread"><em class="citetitle">ATSbufread</em></a>, 
            <a class="link" href="ATScross.html" title="ATScross"><em class="citetitle">ATScross</em></a>, 
            <a class="link" href="ATSinterpread.html" title="ATSinterpread"><em class="citetitle">ATSinterpread</em></a>, 
            <a class="link" href="ATSpartialtap.html" title="ATSpartialtap"><em class="citetitle">ATSpartialtap</em></a>, 
            <a class="link" href="ATSadd.html" title="ATSadd"><em class="citetitle">ATSadd</em></a>, 
            <a class="link" href="ATSaddnz.html" title="ATSaddnz"><em class="citetitle">ATSaddnz</em></a></p>
      </div>
      <div class="refsect1">
        <a id="idp91190624"></a>
        <h2>Credits</h2>
        <p>
            </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Alex Norman</td>
          </tr>
          <tr>
            <td>Seattle,Washington</td>
          </tr>
          <tr>
            <td>2004</td>
          </tr>
        </table>
        <p>
        </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="ATSpartialtap.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="babo.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">ATSpartialtap </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> babo</td>
        </tr>
      </table>
    </div>
  </body>
</html>
